From: Keir Fraser Date: Fri, 10 Oct 2008 09:03:28 +0000 (+0100) Subject: xend: Fix the detection of the upmost bridge in the python function find_parent(). X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14090^2~3 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=de07008fdd4c20763177ff977acbbc544fb850f7;p=xen.git xend: Fix the detection of the upmost bridge in the python function find_parent(). Signed-off-by: Dexuan Cui --- diff --git a/tools/python/xen/util/pci.py b/tools/python/xen/util/pci.py index 56e2c9e633..ef9bb4fda6 100644 --- a/tools/python/xen/util/pci.py +++ b/tools/python/xen/util/pci.py @@ -400,12 +400,8 @@ class PciDevice: lst = target.split('/') parent = lst[len(lst)-2] if parent[0:3] == 'pci': - parent = parent[3:] - lst = parent.split(':') - dom = int(lst[0], 16) - bus = int(lst[1], 16) - dev = 0 - func = 0 + # We have reached the upmost one. + return None else: lst = parent.split(':') dom = int(lst[0], 16) @@ -424,7 +420,10 @@ class PciDevice: (dom, b, d, f) = self.find_parent() dev = dev_parent = PciDevice(dom, b, d, f) while dev_parent.dev_type != DEV_TYPE_PCIe_BRIDGE: - (dom, b, d, f) = dev_parent.find_parent() + parent = dev_parent.find_parent() + if parent is None: + break + (dom, b, d, f) = parent dev = dev_parent dev_parent = PciDevice(dom, b, d, f) return dev